#pragma once
#include "device.h"


class RailSwitch :
	public Device
{
public:
	RailSwitch(void);
	RailSwitch(CWnd* pParent);
	virtual ~RailSwitch(void);
	DEF_CREATE_CALLBACK(RailSwitch)
	DECLARE_SERIAL(RailSwitch)
	virtual void Serialize(CArchive& ar);
	DECLARE_MESSAGE_MAP()
	afx_msg void OnPaint();
public:
	virtual void setWindow(const CPoint& pt1, const CPoint& pt2 = CPoint());
	virtual void setWindow();
	virtual void compressWindow();
	virtual bool setAttr(void);
	virtual bool OnMouseViewMove(const CPoint& viewPt, CPoint& outPt);

	virtual void setSealFrame(CPoint pt[], int height, bool bWnd = false);
	virtual void extenDev(CPoint newPt, int connFlag);
	virtual void setNamePos(void);
public:
	void setSwitchType(void);
	int  height(int width);
	void setConnectFlag(int flag) { connectFlag_ = flag; }
public:
	struct 
	{
		CPoint secPt_[3];
		CPoint norPt_[3];
		CPoint revPt_[3];
		CPoint insuPt_[6];
		CPoint sealPt_[14];
#define SWITCH_TOTAL_PT_COUNT 9 + 6 + 14
		int insuType_[3];
		bool bUp_;
		bool bLeft_;
		bool bNormal_;
	}data_;
	CString secName_;
	CString frontName_;
public:
	enum {
		SEC_LEN = 50, NORMAL_LEN = 40, NAIL_LEN = 10 
	};
	enum {
		SEC_FLAG, NOR_FLAG, REV_FLAG
	};
	int totalLen_;
	int revHeight_;
	int nailHeight_;
	int nailWidth_;

	static int Angle_;
	void connectSwitch();
	void setSealPt(CPoint pt[], CPoint sealPt[3][4], ...);
	void setInsuPt(void);
	void initRevSize(void);
};

